import React, { Component, createRef } from 'react'

export default class App extends Component {
  // #1 把 createRef() 调用的结果赋值实例属性
  inputRef = createRef()

  handleChange = () => {
    // #3 this.inputRef.current => DOM
    console.log(this.inputRef.current.value)
  }
  render() {
    return (
      <div>
        {/* #2 把 this.inputRef 赋值给 ref 属性 */}
        <input type='text' ref={this.inputRef} onChange={this.handleChange} />
      </div>
    )
  }
}
